package com.roncoo.ysq.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.ysq.entity.WebsiteLink;
import com.roncoo.ysq.service.IWebsiteLinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yuanshuaiqiang
 * @since 2021-03-23
 */
@Api("轮播管理")
@RestController
@RequestMapping("/website-link")
public class WebsiteLinkController {

    @Resource
    private IWebsiteLinkService websiteLinkService;

    /**
     * 查询数据
     */
    @ApiOperation("查询所有数据，包括分页，模糊查询")
    @PostMapping("findAll")
    public IPage<WebsiteLink> findAll(Page page,WebsiteLink websiteLink){
        //System.out.println(websiteLink+"111111111");
        IPage<WebsiteLink> all = websiteLinkService.findAll(page,websiteLink);
        //System.out.println(all.getRecords()+"======");
        return all;
    }
    /**
     * 删除数据
     */
    @ApiOperation("根据传回的id删除数据")
    @GetMapping("del/{id}")
    public boolean del(@PathVariable("id")Integer id){
        return websiteLinkService.removeById(id);
    }
    /**
     * 添加数据
     */
    @ApiOperation("根据传回的对象来进行添加")
    @PostMapping("addData")
    public Boolean adddata(WebsiteLink websiteLink){
        return websiteLinkService.save(websiteLink);
    }
    /**
     * 修改数据
     */
    @ApiOperation("根据传回的对象里的id进行修改")
    @PostMapping("updData")
    public Boolean upddata(WebsiteLink websiteLink){
        return websiteLinkService.updateById(websiteLink);
    }
    /**
     * before 查询数据
     */
    @ApiOperation("前端的查询正常状态的数据")
    @GetMapping("findByStatus")
    public List<WebsiteLink> findByStatus(){
        return websiteLinkService.findByStatus();
    }
}

